﻿<?xml version="1.0" encoding="utf-8"?>
<!-- Template Binding :
Default : source is not in the binding Expression. It means that property is directly retrieved from the dataContext (same as WPF binding behavior)
source is in the binding Expression 
-->
<middlewares infodebug="test">

  <middleware uniqueKey="IIS7.5" type="IIS">
    <windowsFeatures type="Collection">
      <windowsFeature uniqueKey="Web-Server" ensure="{templateBindingValue path=ensureFeature }" />
      <windowsFeature uniqueKey="Web-Http-Logging" ensure="{templateBindingValue path=ensureFeature }" />
    </windowsFeatures>

    <template>
      <runtime applicationPoolName="{templateBindingValue path=siteName }" appPoolTemplateFileName="IIS7_ApplicationPool_Template.zip" identityType="NetworkService" managedRuntimeVersion="v4.0" managedPipelineMode="Integrated" />

      <executionContainer siteName="{templateBindingValue path=siteName }" state="{templateBindingValue path=siteState }">
        <logFile iisProperty="logFile" directory="$(Parent:Folders.LoggingDirectory.FullPath)"
                 logExtFileFlags="Date,Time,ClientIP,UserName,SiteName,ServerIP,Method,UriStem,UriQuery,HttpStatus,Win32Status,BytesSent,BytesRecv,TimeTaken,ServerPort,UserAgent,Referer,ProtocolVersion,HttpSubStatus"
                 enabled="{templateBindingValue path=logEnabled, default=true }" logFormat="W3C" />
        
                 
        <!-- Define Folders -->
        <folders type="Hashtable">
          <folder uniqueKey="ExecutionContainerDirectory" path="HTTP.{templateBindingValue path=port}" relative="true" parentFolder="RootMiddlewareDirectory" />
          <folder uniqueKey="LoggingDirectory" path="HTTP.{templateBindingValue path=port}" relative="true" parentFolder="RootLoggingDirectory" />
          <folder uniqueKey="RootExecutionContainerDirectory" path="http.root" relative="true" parentFolder="ExecutionContainerDirectory" />
        </folders>

        <!-- Define a binding Info Template for IIS Site -->
        <siteBindings dataContext="siteBindings" templateBindingType="Collection"
                     port="{templateBindingValue path=port}" protocol="{templateBindingValue path=protocol} "
                     CertificateThumbprint="{templateBindingValue path=CertificateThumbprint}" CertificateStoreName="{templateBindingValue path=CertificateStoreName}"
                     ipAddress="{templateBindingValue path=ipAddress}"/>

      </executionContainer>
  

    </template>
  </middleware>


  <middleware uniqueKey="Tomcat_7.0_Basic"  type="Tomcat">
    <products type="Collection">
      <product uniqueKey="Java" template="Java" version="1.7.0_80" architecture="x64" parentFolder="JavaDeploymentDirectory" packageType="Archive" />
      <product uniqueKey="Tomcat" template="Tomcat" version="7.0.59" architecture="x64" parentFolder="TomcatDeploymentDirectory" packageType="Archive" />
    </products>


    <template>

      <executionContainer executablePath="bin\Tomcat7.exe" executableArguments="//RS//{templateBindingValue path=serviceName }"
                           rootRegistryKey="HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Apache Software Foundation\Procrun 2.0"
                           InstallerPath="bin\services.bat" installArguments="install {templateBindingValue path=serviceName }"
                           httpListenPort="{templateBindingValue path=httpListenPort }" httpsListenPort="{templateBindingValue path=httpsListenPort }"
                           javaHome="$(Dependency:Java.Folders.InstallationDirectory.FullPath)" startupType="{templateBindingValue path=startupType, default=Manual }"
                           serviceName="{templateBindingValue path=serviceName, default=Tomcat7 }">

        <!--Define product dependencies-->
        <dependencies type="Collection">
          <dependency uniqueKey="java" type="product" productUniqueKey="java" />
          <dependency uniqueKey="Tomcat" type="product" productUniqueKey="Tomcat" />
        </dependencies>

        <!-- Define Folders -->
        <folders type="Collection">
          <folder uniqueKey="CatalinaHome" path="$(Dependency:Tomcat.Folders.InstallationDirectory.FullPath)" relative="false" />
          <folder uniqueKey="CatalinaBase" path="" relative="true" parentFolder="CatalinaHome" />
          <folder uniqueKey="LoggingDirectory" path="logs" relative="true" parentfolder="CatalinaBase" />
          <folder uniqueKey="endorsed" path="endorsed" relative="true" parentfolder="CatalinaBase" />
          <folder uniqueKey="ApplicationDirectory" path="webapps" relative="true" parentfolder="CatalinaBase"/>
          <folder uniqueKey="WorkingDirectory" path="work" relative="true" parentfolder="CatalinaBase"/>
          <folder uniqueKey="ConfigurationDirectory" path="conf" relative="true" parentfolder="CatalinaBase">
            <configurationRepository uniqueKey="ConfigurationDirectory" />
          </folder>
          <folder uniqueKey="TemporaryDirectory" path="temp" relative="true" parentfolder="CatalinaBase" />
          <folder uniqueKey="LibraryDirectory" path="lib" relative="true" parentfolder="CatalinaBase" />
        </folders>

        <!-- Define Files -->
        <files type="Collection">
          <file uniqueKey="bootstrap" path="bin\bootstrap.jar" relative="true" parentFolder="CatalinaHome" />
          <file uniqueKey="tomcat-juli" path="bin\tomcat-juli.jar" relative="true" parentFolder="CatalinaHome" />
          <file uniqueKey="LoggingFile" path="logging.properties" relative="true" parentfolder="ConfigurationDirectory" />
          <file uniqueKey="jdbOracleDriver" path="ojdbc7.jar" source="$(Dependency:Java.Folders.InstallationDirectory.FullPath)\test.xml" parentfolder="LibraryDirectory"/>
        </files>

        <!-- Define direct registry keys-->
        <registry type="Collection">
          <!-- Tomcat Log Configuration -->
          <registry uniqueKey="$(Container:rootRegistryKey)\$(Container:serviceName)\Parameters\Log" ValueName="Path" ValueType="string" ValueData="$(Container:Folders.LoggingDirectory.FullPath)"/>
          <registry uniqueKey="$(Container:rootRegistryKey)\$(Container:serviceName)\Parameters\Log" ValueName="StdError" ValueType="string" ValueData="{templateBindingValue path=StdError, DefaultValue=auto }" />
          <registry uniqueKey="$(Container:rootRegistryKey)\$(Container:serviceName)\Parameters\Log" ValueName="StdOutput" ValueType="string" ValueData="{templateBindingValue path=StdOutput, DefaultValue=auto }" />

          <!-- Tomcat Java Configuration -->
          <registry uniqueKey="$(Container:rootRegistryKey)\$(Container:serviceName)\Parameters\Java" ValueName="Jvm" ValueType="string"  ValueData="$(Dependency:Java.Folders.InstallationDirectory.FullPath)\jre\bin\server\jvm.dll" />
          <registry uniqueKey="$(Container:rootRegistryKey)\$(Container:serviceName)\Parameters\Java" ValueName="JvmMs" ValueType="Dword" ValueData="{templateBindingValue path=JvmMs, DefaultValue=128 }" />
          <registry uniqueKey="$(Container:rootRegistryKey)\$(Container:serviceName)\Parameters\Java" ValueName="JvmMx" ValueType="Dword"  ValueData="{templateBindingValue path=JvmMx, DefaultValue=256 }" />
          <registry uniqueKey="$(Container:rootRegistryKey)\$(Container:serviceName)\Parameters\Java" ValueName="Options" ValueType="Multistring" ValueData="-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager" />
          <registry uniqueKey="$(Container:rootRegistryKey)\$(Container:serviceName)\Parameters\Java" ValueName="Options" ValueType="Multistring" ValueData="-Dcatalina.home=$(Container:Folders.CatalinaHome.FullPath)" />
          <registry uniqueKey="$(Container:rootRegistryKey)\$(Container:serviceName)\Parameters\Java" ValueName="Options" ValueType="Multistring" ValueData="-Dcatalina.base=$(Container:Folders.CatalinaBase.FullPath)" />
          <registry uniqueKey="$(Container:rootRegistryKey)\$(Container:serviceName)\Parameters\Java" ValueName="Options" ValueType="Multistring" ValueData="-Djava.endorsed.dirs=$(Container:Folders.endorsed.FullPath)" />
          <registry uniqueKey="$(Container:rootRegistryKey)\$(Container:serviceName)\Parameters\Java" ValueName="Options" ValueType="Multistring" ValueData="-Djava.util.logging.config.file=$(Container:Files.LoggingFile.FullPath)" />
          <registry uniqueKey="$(Container:rootRegistryKey)\$(Container:serviceName)\Parameters\Java" ValueName="Options" ValueType="Multistring" ValueData="-Djava.io.tmpdir=$(Container:Folders.TemporaryDirectory.FullPath)" />

          <!-- Tomcat Start Configuration -->
          <registry uniqueKey="$(Container:rootRegistryKey)\$(Container:serviceName)\Parameters\Start" ValueName="Class" ValueType="string" ValueData="org.apache.catalina.startup.Bootstrap" />
          <registry uniqueKey="$(Container:rootRegistryKey)\$(Container:serviceName)\Parameters\Start" ValueName="Mode" ValueType="string" ValueData="jvm" />
          <registry uniqueKey="$(Container:rootRegistryKey)\$(Container:serviceName)\Parameters\Start" ValueName="Params" ValueType="Multistring" ValueData="start" />


          <registry uniqueKey="$(Container:rootRegistryKey)\$(Container:serviceName)\Parameters\Stop" ValueName="Class" ValueType="string" ValueData="org.apache.catalina.startup.Bootstrap" />
          <registry uniqueKey="$(Container:rootRegistryKey)\$(Container:serviceName)\Parameters\Stop" ValueName="Mode" ValueType="string" ValueData="jvm" />
          <registry uniqueKey="$(Container:rootRegistryKey)\$(Container:serviceName)\Parameters\Stop" ValueName="Params" ValueType="Multistring" ValueData="stop" />

          <!-- Tomcat installation folder configuration-->
          <registry uniqueKey="$(Container:rootRegistryKey)\$(Container:serviceName)\Parameters\Java" ValueName="Classpath" ValueType="string" MergePattern=";" ValueData="$(Container:Files.bootstrap.FullPath)"/>
          <registry uniqueKey="$(Container:rootRegistryKey)\$(Container:serviceName)\Parameters\Java" ValueName="Classpath" ValueType="string" MergePattern=";" ValueData="$(Container:Files.tomcat-juli.FullPath)"/>
          <registry uniqueKey="$(Container:rootRegistryKey)\$(Container:serviceName)\Parameters\Start" ValueName="WorkingPath" ValueType="string" ValueData="$(Container:Folders.CatalinaHome.FullPath)"/>
          <registry uniqueKey="$(Container:rootRegistryKey)\$(Container:serviceName)\Parameters\Stop" ValueName="WorkingPath" ValueType="string" ValueData="$(Container:Folders.CatalinaHome.FullPath)"/>

        </registry>
      </executionContainer>

    </template>

  </middleware>

</middlewares>